	package com.shop2cn.iapi.accounting.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.accounting.parameter.AccountEntryBean;
import com.shop2cn.iapi.accounting.parameter.AccountingBean;
import com.shop2cn.iapi.accounting.parameter.AccountingItemBean;
import com.shop2cn.iapi.accounting.parameter.GetAccountEntryListBean;
import com.shop2cn.iapi.accounting.service.GetAccountEntryListCall;
import com.ymatou.iapi.userregister.parameter.UserRegisterInfoRequestDtoBean;
import com.ymatou.iapi.userregister.service.UserRegisterInfoRequestDtoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymt.utils.tag.P3;
import com.ymttest.business.service.JUserCallService;
import com.ymttest.business.service.shenqi.AccountCallServiceV2;
import com.ymttest.database.model.Account;
import com.ymttest.database.model.AccountEntry;
import com.ymttest.database.sqlwapper.AccountWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;
import com.ymttest.utils.constant.ECode;

/**
 * 获取账户资金流水接口 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GetAccountEntryList {
	private static GetAccountEntryListBean getaccountentrylistBean;
	private static GetAccountEntryListCall getaccountentrylistCall;
	private static String userid3;
	private static int accountType;
	private static int currencyType;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取账户资金流水接口");
		try {
			userid3 = EnvSetup.getData("accountuid3");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Before
	public void caseUp() {
		getaccountentrylistBean = new GetAccountEntryListBean();
		getaccountentrylistCall = new GetAccountEntryListCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getaccountentrylistCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	// 根据总记录数，每页数 计算总共有多少页
	private int getTotalPage(int totalRecords, int pageSize) {
		int totalPage;
		if (totalRecords % pageSize > 0) {
			totalPage = (totalRecords / pageSize) + 1;
		} else {
			totalPage = (totalRecords / pageSize);
		}
		return totalPage;
	}

	// 数据库检查点
	private void dbCheckpoint(List<AccountEntry> dbList, ArrayList<AccountEntryBean> returnAccountList) {
		if (returnAccountList.size() > 0) {
			for (int i = 0; i < returnAccountList.size(); i++) {
				Logger.comment("第" + (i + 1) + "条记录");
				Logger.verifyEquals(dbList.get(i).getAccountId(), returnAccountList.get(i).getAccountId(),
						"验证接口返回AccountId跟数据库是否一致");
				Logger.verifyEquals(dbList.get(i).getEntryId(), returnAccountList.get(i).getEntryId(),
						"验证接口返回EntryId跟数据库是否一致");
				Logger.verifyEquals(accountType, returnAccountList.get(i).getAccountType(),
						"验证接口返回AccountType跟数据库是否一致");
				Logger.verifyEquals(currencyType, returnAccountList.get(i).getCurrencyType(),
						"验证接口返回CurrencyType跟数据库是否一致");
						
				Logger.verifyEquals(0, dbList.get(i).getAmount().compareTo(returnAccountList.get(i).getAmount()),
						"验证接口返回Amount:" + returnAccountList.get(i).getAmount() + "跟数据库是否一致");
				Logger.verifyEquals(0,
						dbList.get(i).getFreezeAmount().compareTo(returnAccountList.get(i).getFreezeAmount()),
						"验证接口返回FreezeAmount:" + returnAccountList.get(i).getFreezeAmount() + "跟数据库是否一致");
				Logger.verifyEquals(0,
						dbList.get(i).getAvailAmount().compareTo(returnAccountList.get(i).getAvailAmount()),
						"验证接口返回AvailAmount:" + returnAccountList.get(i).getAvailAmount() + "跟数据库是否一致");
				Logger.verifyEquals(dbList.get(i).getEntryType(), returnAccountList.get(i).getEntryType(),
						"验证接口返回EntryType跟数据库是否一致");
				Logger.verifyEquals(dbList.get(i).getUserId(), returnAccountList.get(i).getUserId(),
						"验证接口返回UserId跟数据库是否一致");
				Logger.verifyEquals(dbList.get(i).getBizCode(), returnAccountList.get(i).getBizCode(),
						"验证接口返回BizCode跟数据库是否一致");
				Logger.verifyEquals(dbList.get(i).getBizNo(), returnAccountList.get(i).getBizNo(),
						"验证接口返回BizNo跟数据库是否一致");
				Logger.verifyEquals(dbList.get(i).getOriginalNo(), returnAccountList.get(i).getOriginalNo(),
						"验证接口返回OriginalNo跟数据库是否一致");

				Logger.verifyEquals(
						YMTDateUtil.getFormatTime(dbList.get(i).getAccountingDate(), "yyyy-MM-dd HH:mm:ss"),
						returnAccountList.get(i).getAccountingDate(), "验证接口返回AccountingDate跟数据库是否一致");
				Logger.verifyEquals(
						YMTDateUtil.getFormatTime(dbList.get(i).getUpdateTime(), "yyyy-MM-dd HH:mm:ss"),
						returnAccountList.get(i).getUpdateTime(), "验证接口返回UpdateTime跟数据库是否一致");
				Logger.verifyEquals(
						YMTDateUtil.getFormatTime(dbList.get(i).getCreateTime(), "yyyy-MM-dd HH:mm:ss"),
						returnAccountList.get(i).getCreateTime(), "验证接口返回CreateTime跟数据库是否一致");

				Logger.verifyEquals(dbList.get(i).getOperator(), returnAccountList.get(i).getOperator(),
						"验证接口返回Operator跟数据库是否一致");
				Logger.verifyEquals(dbList.get(i).getMemo(), returnAccountList.get(i).getMemo(), "验证接口返回Memo跟数据库是否一致");
				Logger.verifyEquals(dbList.get(i).getAppId(), returnAccountList.get(i).getAppId(),
						"验证接口返回AppId跟数据库是否一致");
				Logger.verifyEquals(dbList.get(i).getServerIp(), returnAccountList.get(i).getServerIp(),
						"验证接口返回ServerIp跟数据库是否一致");
				Logger.verifyEquals(dbList.get(i).getClientIp(), returnAccountList.get(i).getClientIp(),
						"验证接口返回ClientIp跟数据库是否一致");
				Logger.verifyEquals(dbList.get(i).getRequestId(), returnAccountList.get(i).getRequestId(),
						"验证接口返回RequestId跟数据库是否一致");
			}
		}

	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAccountEntryList_001() {
		Logger.start(true, "获取账户资金流水成功");
		try {
			int newuid = AccountCallServiceV2.getNewUid();
			String accountId = AccountCallServiceV2.getAccountId(newuid);
			AccountCallServiceV2.resetAccount(accountId, new BigDecimal(10), new BigDecimal(10));
			int pageIndex = 1;
			int pageSize = 2;
			getaccountentrylistBean.setAccountId(accountId);
			getaccountentrylistBean.setAppId("AutoTest");
			getaccountentrylistBean.setPageIndex(pageIndex);
			getaccountentrylistBean.setPageSize(pageSize);
			getaccountentrylistCall.setData(getaccountentrylistBean);
			getaccountentrylistCall.callService();
			// 查询数据库
			List<AccountEntry> list = new AccountWapper().selectAccountEntry(accountId);
			List<Account> accountInfo = new AccountWapper().selectAccountInfo(accountId);
			//重置为0
			accountType=-1;
			currencyType=-1;
			if (accountInfo.size()>0){
				accountType=accountInfo.get(0).getAccountType();
				currencyType=accountInfo.get(0).getCurrencyType();			
			}		
			// 接口返回数据
			ArrayList<AccountEntryBean> returnAccountList = getaccountentrylistCall.getReturnAccountList();
			Logger.comment("接口返回记录数:" + returnAccountList.size());
			Logger.verifyEquals(list.size(), getaccountentrylistCall.getTotalRecords(), "验证接口返回总记录数跟数据库是否一致");
			Logger.verifyEquals(getTotalPage(list.size(), pageSize), getaccountentrylistCall.getTotalPages(),
					"验证接口返回总页数跟数据库是否一致");
			// 分割从数据库查询出的list
			List<AccountEntry> subList = null;
			// 最后一页
			if (pageIndex == getTotalPage(list.size(), pageSize)) {
				subList = list.subList((pageIndex - 1) * pageSize, list.size());
			} else {
				subList = list.subList((pageIndex - 1) * pageSize, pageIndex * pageSize);
			}
			// 数据库检查
			dbCheckpoint(subList, returnAccountList);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GetAccountEntryList_002() {
		Logger.start(true, "每页显示条数大于总记录数,查询资金流水成功");
		try {
			int newuid = AccountCallServiceV2.getNewUid();
			String accountId = AccountCallServiceV2.getAccountId(newuid);
			AccountCallServiceV2.resetAccount(accountId, new BigDecimal(10), new BigDecimal(10));
			// 查询数据库
			List<AccountEntry> list = new AccountWapper().selectAccountEntry(accountId);
			List<Account> accountInfo = new AccountWapper().selectAccountInfo(accountId);
			//重置为0
			accountType=-1;
			currencyType=-1;
			if (accountInfo.size()>0){
				accountType=accountInfo.get(0).getAccountType();
				currencyType=accountInfo.get(0).getCurrencyType();			
			}	
			int pageIndex = 1;
			int pageSize = list.size() + 1;
			getaccountentrylistBean.setAccountId(accountId);
			getaccountentrylistBean.setAppId("AutoTest");
			getaccountentrylistBean.setPageIndex(pageIndex);
			getaccountentrylistBean.setPageSize(pageSize);
			getaccountentrylistCall.setData(getaccountentrylistBean);
			getaccountentrylistCall.callService();
			// 接口返回数据
			ArrayList<AccountEntryBean> returnAccountList = getaccountentrylistCall.getReturnAccountList();
			Logger.comment("接口返回记录数:" + returnAccountList.size());
			Logger.verifyEquals(list.size(), getaccountentrylistCall.getTotalRecords(), "验证接口返回总记录数跟数据库是否一致");
			Logger.verifyEquals(1, getaccountentrylistCall.getTotalPages(), "验证接口返回总页数跟数据库是否一致");
			// 数据库检查
			dbCheckpoint(list, returnAccountList);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GetAccountEntryList_003() {
		Logger.start(false, "每页显示条数大于总记录数,当前页码不为第一页,查询结果返回空");
		try {
			String accountId = "01010021000003";
			// 查询数据库
			List<AccountEntry> list = new AccountWapper().selectAccountEntry(accountId);
			int pageIndex = 2;
			int pageSize = list.size() + 1;
			getaccountentrylistBean.setAccountId(accountId);
			getaccountentrylistBean.setAppId("AutoTest");
			getaccountentrylistBean.setPageIndex(pageIndex);
			getaccountentrylistBean.setPageSize(pageSize);
			getaccountentrylistCall.setData(getaccountentrylistBean);
			getaccountentrylistCall.callService();
			// Logger.comment("getaccountentrylistCall response:" +
			// getaccountentrylistCall.getReturnData());
			// 接口返回数据
			ArrayList<AccountEntryBean> returnAccountList = getaccountentrylistCall.getReturnAccountList();
			Logger.comment("接口返回记录数:" + returnAccountList.size());
			Logger.verifyEquals(list.size(), getaccountentrylistCall.getTotalRecords(), "验证接口返回总记录数跟数据库是否一致");
			Logger.verifyEquals(1, getaccountentrylistCall.getTotalPages(), "验证接口返回总页为1");
			//逻辑变更:如果页数超出则返回最后一页数据
			Logger.verifyEquals(list.size(), getaccountentrylistCall.getTotalRecords(), "返回最后一页数据");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	//新做一条数据来验证
	public void Tc_GetAccountEntryList_004() {
		Logger.start(true, "检查所有分页的数据跟数据库是否一致");
		try {
			UserRegisterInfoRequestDtoBean urb = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall uc = JUserCallService.UserRegisterInfoRequestDtoCall(urb);
			Integer uid = uc.getUserid();
			// 设置账户余额
			String aid = AccountCallServiceV2.getAccountId(uid);
			for (int i = 0; i < 10; i++) {
				AccountCallServiceV2.resetAccount(aid, new BigDecimal(i*10), new BigDecimal(0));
				Thread.sleep(50);
			}
			AccountCallServiceV2.resetAccount(aid, new BigDecimal("1000"), new BigDecimal("100"));
			Thread.sleep(50);
			int pageIndex = 1;
			int pageSize = 5;
			// 查询数据库
			List<AccountEntry> list = new AccountWapper().selectAccountEntry(aid);
			List<Account> accountInfo = new AccountWapper().selectAccountInfo(aid);
			Logger.comment("total size:"+list.size());
			//重置为0
			accountType=-1;
			currencyType=-1;
			if (accountInfo.size()>0){
				accountType=accountInfo.get(0).getAccountType();
				currencyType=accountInfo.get(0).getCurrencyType();					
			}	
			// 计算有多少页
			int dbTotalPage = getTotalPage(list.size(), pageSize);
			// 分割从数据库查询出的list
			List<AccountEntry> subList = null;
			getaccountentrylistBean.setAccountId(aid);
			getaccountentrylistBean.setAppId("AutoTest");
			getaccountentrylistBean.setPageSize(pageSize);
			for (pageIndex = 1; pageIndex < dbTotalPage + 1; pageIndex++) {
				// 验证第一第二页和最后一页
				if (pageIndex <= 2 || pageIndex == dbTotalPage) {
					getaccountentrylistBean.setPageIndex(pageIndex);
					getaccountentrylistCall.setData(getaccountentrylistBean);
					getaccountentrylistCall.callService();
					// 接口返回数据
					ArrayList<AccountEntryBean> returnAccountList = getaccountentrylistCall.getReturnAccountList();
					if (pageIndex == 1) {
						Logger.comment("接口返回记录数:" + returnAccountList.size());
						Logger.verifyEquals(list.size(), getaccountentrylistCall.getTotalRecords(),
								"验证接口返回总记录数跟数据库是否一致");
						Logger.verifyEquals(dbTotalPage, getaccountentrylistCall.getTotalPages(), "验证接口返回总页数跟数据库是否一致");
					}
					// 最后一页
					if (pageIndex == dbTotalPage) {
						subList = list.subList((pageIndex - 1) * pageSize, list.size());
					} else {
						subList = list.subList((pageIndex - 1) * pageSize, pageIndex * pageSize);
					}
					Logger.comment("第" + pageIndex + "页");
					dbCheckpoint(subList, returnAccountList);
				}
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetAccountEntryList_005() {
		Logger.start(false, "账户编号不存在,获取资金流水为空");
		try {
			String accountId = "0101002100000";
			int pageIndex = 1;
			int pageSize = 10;
			getaccountentrylistBean.setAccountId(accountId);
			getaccountentrylistBean.setAppId("AutoTest");
			getaccountentrylistBean.setPageIndex(pageIndex);
			getaccountentrylistBean.setPageSize(pageSize);
			getaccountentrylistCall.setData(getaccountentrylistBean);
			getaccountentrylistCall.callService();
			// 查询数据库
			List<AccountEntry> list = new AccountWapper().selectAccountEntry(accountId);
			// 接口返回数据
			ArrayList<AccountEntryBean> returnAccountList = getaccountentrylistCall.getReturnAccountList();
			Logger.comment("接口返回记录数:" + returnAccountList.size());
			Logger.verifyEquals(list.size(), getaccountentrylistCall.getTotalRecords(), "验证接口返回总记录数跟数据库是否一致");
			Logger.verifyEquals(0, getaccountentrylistCall.getTotalPages(), "验证接口返回总页为0");
			Logger.verifyEquals("[]", getaccountentrylistCall.getAccountEntryList(), "验证接口查询结果返回为空");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetAccountEntryList_006() {
		Logger.start(false, "账户编号为空,返回空");
		try {
			int pageIndex = 1;
			int pageSize = 10;
			// getaccountentrylistBean.setAccountId(accountId);
			getaccountentrylistBean.setAppId("AutoTest");
			getaccountentrylistBean.setPageIndex(pageIndex);
			getaccountentrylistBean.setPageSize(pageSize);
			getaccountentrylistCall.setData(getaccountentrylistBean);
			getaccountentrylistCall.callService();
			Logger.verifyEquals(2, getaccountentrylistCall.getStatuscode(), "验证接口查询结果返回statusCode为2");
			Logger.verifyEquals(ECode.ACCOUNT_AID_UID_NOT_NULL, getaccountentrylistCall.getMsg(), "验证接口查询错误提示信息");
			Logger.verifyIsNull(getaccountentrylistCall.getData(), "验证接口查询结果返回为空");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@SuppressWarnings("rawtypes")
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetAccountEntryList_007() {
		Logger.start(true, "每页显示的条数为空,返回默认查询条件(最多15条)");
		try {
			String accountId = "01010021000003";
			int pageIndex = 1;
			getaccountentrylistBean.setAccountId(accountId);
			getaccountentrylistBean.setAppId("AutoTest");
			getaccountentrylistBean.setPageIndex(pageIndex);
			// getaccountentrylistBean.setPageSize(pageSize);
			getaccountentrylistCall.setData(getaccountentrylistBean);
			getaccountentrylistCall.callService();
			Logger.verifyEquals(0, getaccountentrylistCall.getStatuscode(), "验证接口查询结果返回statusCode为0");
			Logger.verifyEquals(ECode.ACCOUNT_SUCCESS, getaccountentrylistCall.getMsg(), "验证接口查询结果返回为空");
			Logger.verifyEquals(true,
					((List) ((Map) getaccountentrylistCall.getMap().get("Data")).get("AccountEntryList")).size() <= 15,
					"验证默认返回条数,最多15条");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetAccountEntryList_008() {
		Logger.start(true, "当前页码为空,返回默认查询条件(第一页)");
		try {
			String accountId = "01010021000003";

			int pageSize = 2;
			getaccountentrylistBean.setAccountId(accountId);
			getaccountentrylistBean.setAppId("AutoTest");
			// getaccountentrylistBean.setPageIndex(pageIndex);
			getaccountentrylistBean.setPageSize(pageSize);
			getaccountentrylistCall.setData(getaccountentrylistBean);
			getaccountentrylistCall.callService();
			Logger.verifyEquals(0, getaccountentrylistCall.getStatuscode(), "验证接口查询结果返回statusCode");
			Logger.verifyEquals(ECode.ACCOUNT_SUCCESS, getaccountentrylistCall.getMsg(), "验证接口查询结果返回为空");
			Logger.verifyEquals(pageSize, getaccountentrylistCall.getAccountEntryListData().getAccountEntryList()
					.size(), "验证条数");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetAccountEntryList_009() {
		Logger.start(false, "应用编号为空,获取资金流水失败");
		try {
			String accountId = "01010021000003";
			int pageIndex = 1;
			int pageSize = 10;
			getaccountentrylistBean.setAccountId(accountId);
			// getaccountentrylistBean.setAppId("AutoTest");
			getaccountentrylistBean.setPageIndex(pageIndex);
			getaccountentrylistBean.setPageSize(pageSize);
			getaccountentrylistCall.setData(getaccountentrylistBean);
			getaccountentrylistCall.callService();
			Logger.verifyEquals(2, getaccountentrylistCall.getStatuscode(), "验证接口查询结果返回statusCode");
			Logger.verifyEquals("AppId不能为空！", getaccountentrylistCall.getMsg(), "验证接口查询错误提示信息");
			Logger.verifyIsNull(getaccountentrylistCall.getData(), "验证接口查询结果返回为空");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetAccountEntryList_010() {
		Logger.start(true, "使用userid查询,获取资金流水成功");
		try {
			String userid = userid3;
			int pageIndex = 1;
			int pageSize = 10;
			getaccountentrylistBean.setUserId(Integer.valueOf(userid));
			getaccountentrylistBean.setAppId("AutoTest");
			getaccountentrylistBean.setPageIndex(pageIndex);
			getaccountentrylistBean.setPageSize(pageSize);
			getaccountentrylistCall.setData(getaccountentrylistBean);
			getaccountentrylistCall.callService();
			Logger.verifyEquals(0, getaccountentrylistCall.getStatuscode(), "验证接口查询结果返回statusCode");
			Logger.verifyEquals(ECode.ACCOUNT_SUCCESS, getaccountentrylistCall.getMsg(), "验证提示信息成功");

			int allrecords = new AccountWapper().selectCountByUserid(Integer.valueOf(userid));
			Logger.verifyEquals(allrecords, getaccountentrylistCall.getTotalRecords(), "验证总量");
			// 验证返回是userid
			ArrayList<AccountEntryBean> returnAccountList = getaccountentrylistCall.getReturnAccountList();
			for (AccountEntryBean accountEntryBean : returnAccountList) {
				Logger.verifyEquals(Integer.valueOf(userid), accountEntryBean.getUserId(), "验证Userid");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetAccountEntryList_011() {
		Logger.start(true, "输入根据用户ID+时间段查询 条件,获取资金流水成功");
		try {
			String userid = userid3;
			int pageIndex = 1;
			int pageSize = 10;
			getaccountentrylistBean.setUserId(Integer.valueOf(userid));
			getaccountentrylistBean.setAppId("AutoTest");
			String beginTime=YMTDateUtil.getBeforeOrNextDay(-10);
			String endTime=YMTDateUtil.getBeforeOrNextHour(1);		
			getaccountentrylistBean.setBeginTime(beginTime);
			getaccountentrylistBean.setEndTime(endTime);
			getaccountentrylistBean.setPageIndex(pageIndex);
			getaccountentrylistBean.setPageSize(pageSize);
			getaccountentrylistCall.setData(getaccountentrylistBean);
			getaccountentrylistCall.callService();
			Logger.verifyEquals(0, getaccountentrylistCall.getStatuscode(), "验证接口查询结果返回statusCode");
			Logger.verifyEquals(ECode.ACCOUNT_SUCCESS, getaccountentrylistCall.getMsg(), "验证提示信息成功");
			Map<String, Object> m=new HashMap<>();
			m.put("UserId", userid);
			m.put("BeginTime", beginTime);
			m.put("EndTime", endTime);
			List<AccountEntry> list = new AccountWapper().selectAccountEntryAndInfo(m);			
			Logger.verifyEquals(list.size(), getaccountentrylistCall.getTotalRecords(), "验证总量");
			// 验证返回是userid
			ArrayList<AccountEntryBean> returnAccountList = getaccountentrylistCall.getReturnAccountList();
			for (AccountEntryBean accountEntryBean : returnAccountList) {
				Logger.verifyEquals(Integer.valueOf(userid), accountEntryBean.getUserId(), "验证Userid");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetAccountEntryList_012() {
		Logger.start(true, "输入根据用户ID+时间段+流水类型查询条件,获取资金流水成功");
		try {
			String userid = userid3;
			int pageIndex = 1;
			int pageSize = 10;
			getaccountentrylistBean.setUserId(Integer.valueOf(userid));
			getaccountentrylistBean.setAppId("AutoTest");
			String beginTime=YMTDateUtil.getBeforeOrNextDay(-1);
			String endTime=YMTDateUtil.getBeforeOrNextHour(1);		
			getaccountentrylistBean.setBeginTime(beginTime);
			getaccountentrylistBean.setEndTime(endTime);
			int entryType=2;
			getaccountentrylistBean.setEntryType(entryType);
			getaccountentrylistBean.setPageIndex(pageIndex);
			getaccountentrylistBean.setPageSize(pageSize);
			getaccountentrylistCall.setData(getaccountentrylistBean);
			getaccountentrylistCall.callService();
			Logger.verifyEquals(0, getaccountentrylistCall.getStatuscode(), "验证接口查询结果返回statusCode");
			Logger.verifyEquals(ECode.ACCOUNT_SUCCESS, getaccountentrylistCall.getMsg(), "验证提示信息成功");
			Map<String, Object> m=new HashMap<>();
			m.put("UserId",userid);
			m.put("BeginTime", beginTime);
			m.put("EndTime", endTime);
			m.put("Entrytype", entryType);
			List<AccountEntry> list = new AccountWapper().selectAccountEntryAndInfo(m);			
			Logger.verifyEquals(list.size(), getaccountentrylistCall.getTotalRecords(), "验证总量");
			// 验证返回是userid
			ArrayList<AccountEntryBean> returnAccountList = getaccountentrylistCall.getReturnAccountList();
			for (AccountEntryBean accountEntryBean : returnAccountList) {
				Logger.verifyEquals(Integer.valueOf(userid), accountEntryBean.getUserId(), "验证Userid");
			}
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetAccountEntryList_013() {
		Logger.start(true, "输入根据根据账户ID+时间段查询条件,获取资金流水成功");
		try {
			int newuid = AccountCallServiceV2.getNewUid();
			String accountId = AccountCallServiceV2.getAccountId(newuid);
			AccountCallServiceV2.resetAccount(accountId, new BigDecimal(10), new BigDecimal(10));
			// 查询数据库
			List<AccountEntry> list = new AccountWapper().selectAccountEntry(accountId);
			List<Account> accountInfo = new AccountWapper().selectAccountInfo(accountId);
			//重置
			accountType=-1;
			currencyType=-1;
			if (accountInfo.size()>0){
				accountType=accountInfo.get(0).getAccountType();
				currencyType=accountInfo.get(0).getCurrencyType();			
			}	
			int pageIndex = 1;
			int pageSize = list.size() + 1;
			getaccountentrylistBean.setAccountId(accountId);
			getaccountentrylistBean.setAppId("AutoTest");
			getaccountentrylistBean.setPageIndex(pageIndex);
			getaccountentrylistBean.setPageSize(pageSize);
			String beginTime=YMTDateUtil.getBeforeOrNextHour(-1);
			String endTime=YMTDateUtil.getBeforeOrNextHour(1);		
			getaccountentrylistBean.setBeginTime(beginTime);
			getaccountentrylistBean.setEndTime(endTime);
			getaccountentrylistCall.setData(getaccountentrylistBean);
			getaccountentrylistCall.callService();
			// 接口返回数据
			ArrayList<AccountEntryBean> returnAccountList = getaccountentrylistCall.getReturnAccountList();
			Logger.comment("接口返回记录数:" + returnAccountList.size());
			Logger.verifyEquals(list.size(), getaccountentrylistCall.getTotalRecords(), "验证接口返回总记录数跟数据库是否一致");
			Logger.verifyEquals(1, getaccountentrylistCall.getTotalPages(), "验证接口返回总页数跟数据库是否一致");
			// 数据库检查
			dbCheckpoint(list, returnAccountList);			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetAccountEntryList_014() {
		Logger.start(true, "输入根据用户编号 + 账户类型 + 货币类型 + 出入账类型入账 +流水类型 + 时间段查询组合查询条件,获取资金流水成功");
		try {
			String userid = userid3;
			int pageIndex = 1;
			int pageSize = 10;
			getaccountentrylistBean.setUserId(Integer.valueOf(userid));
			getaccountentrylistBean.setAppId("AutoTest");
			String beginTime=YMTDateUtil.getBeforeOrNextDay(-1);
			String endTime=YMTDateUtil.getBeforeOrNextHour(1);		
			getaccountentrylistBean.setBeginTime(beginTime);
			getaccountentrylistBean.setEndTime(endTime);
			int accountingType=-1;
			getaccountentrylistBean.setAccountingType(accountingType);
			int entryType=2;
			getaccountentrylistBean.setEntryType(entryType);
			int accountType=1;
			getaccountentrylistBean.setAccountType(accountType);
			int currencyType=1;
			getaccountentrylistBean.setCurrencyType(currencyType);
			getaccountentrylistBean.setPageIndex(pageIndex);
			getaccountentrylistBean.setPageSize(pageSize);
			getaccountentrylistCall.setData(getaccountentrylistBean);
			getaccountentrylistCall.callService();
			Logger.verifyEquals(0, getaccountentrylistCall.getStatuscode(), "验证接口查询结果返回statusCode");
			Logger.verifyEquals(ECode.ACCOUNT_SUCCESS, getaccountentrylistCall.getMsg(), "验证提示信息成功");			
			Map<String, Object> m=new HashMap<>();
			m.put("UserId",userid);
			m.put("BeginTime", beginTime);
			m.put("EndTime", endTime);
			m.put("Entrytype", entryType);
			m.put("AccountType", accountType);
			m.put("CurrencyType", currencyType);
			m.put("AccountingType",accountingType);
			List<AccountEntry> list = new AccountWapper().selectAccountEntryAndInfo(m);
			Logger.verifyEquals(list.size(), getaccountentrylistCall.getTotalRecords(), "验证总量");
			// 验证返回是userid
			ArrayList<AccountEntryBean> returnAccountList = getaccountentrylistCall.getReturnAccountList();
			for (AccountEntryBean accountEntryBean : returnAccountList) {
				Logger.verifyEquals(Integer.valueOf(userid), accountEntryBean.getUserId(), "验证Userid");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetAccountEntryList_015() {
		Logger.start(true, "输入根据用户编号 + 账户类型 + 货币类型 + 出入账类型为支出 +流水类型 + 时间段查询组合查询条件,获取资金流水成功");
		try {
			String userid = userid3;
			int pageIndex = 1;
			int pageSize = 50;
			getaccountentrylistBean.setUserId(Integer.valueOf(userid));
			getaccountentrylistBean.setAppId("AutoTest");
			String beginTime=YMTDateUtil.getBeforeOrNextDay(-1);
			String endTime=YMTDateUtil.getBeforeOrNextHour(1);		
			getaccountentrylistBean.setBeginTime(beginTime);
			getaccountentrylistBean.setEndTime(endTime);
			int accountingType=1;
			getaccountentrylistBean.setAccountingType(accountingType);
			int entryType=2;
			getaccountentrylistBean.setEntryType(entryType);
			int accountType=1;
			getaccountentrylistBean.setAccountType(accountType);
			int currencyType=1;
			getaccountentrylistBean.setCurrencyType(currencyType);
			getaccountentrylistBean.setPageIndex(pageIndex);
			getaccountentrylistBean.setPageSize(pageSize);
			getaccountentrylistCall.setData(getaccountentrylistBean);
			getaccountentrylistCall.callService();
			Logger.verifyEquals(0, getaccountentrylistCall.getStatuscode(), "验证接口查询结果返回statusCode");
			Logger.verifyEquals(ECode.ACCOUNT_SUCCESS, getaccountentrylistCall.getMsg(), "验证提示信息成功");
			
			Map<String, Object> m=new HashMap<>();
			m.put("UserId",userid);
			m.put("BeginTime", beginTime);
			m.put("EndTime", endTime);
			m.put("Entrytype", entryType);
			m.put("AccountType", accountType);
			m.put("CurrencyType", currencyType);
			m.put("AccountingType",accountingType);
			List<AccountEntry> list = new AccountWapper().selectAccountEntryAndInfo(m);
			Logger.verifyEquals(list.size(), getaccountentrylistCall.getTotalRecords(), "验证总量");
			// 验证返回是userid
			ArrayList<AccountEntryBean> returnAccountList = getaccountentrylistCall.getReturnAccountList();
			for (AccountEntryBean accountEntryBean : returnAccountList) {
				Logger.verifyEquals(Integer.valueOf(userid), accountEntryBean.getUserId(), "验证Userid");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetAccountEntryList_016() {
		Logger.start(true, "输入根据bizcode+用户编号 + 账户类型 + 货币类型 + 出入账类型为支出 +流水类型 + 时间段查询组合查询条件,获取资金流水成功");
		try {
			Integer userid = AccountCallServiceV2.getNewUid();
			String aid=AccountCallServiceV2.getAccountId(userid);
			Integer bizCode=100004;
			int pageIndex = 1;
			int pageSize = 50;
			int size=new Random().nextInt(3)+1;
			AccountingBean accountingBean=new AccountingBean();
			List<AccountingItemBean> AccountingItems = new ArrayList<AccountingItemBean>();
			for (int i = 0; i < size; i++) {
				String oNo = TestDataManager.getRandomUUID().toString();
				AccountingItems.add(AccountCallServiceV2.getFundinBean(aid, new BigDecimal("1"), bizCode, oNo));
			}
			String oNo = TestDataManager.getRandomUUID().toString();
			//输入一个其他条件
			AccountingItems.add(AccountCallServiceV2.getFundinBean(aid, new BigDecimal("1"), 100001, oNo));
			accountingBean.setAppId("autotest");
			accountingBean.setAccountingItems(AccountingItems);
			AccountCallServiceV2.Accounting(accountingBean);
			
			getaccountentrylistBean.setUserId(userid);
			getaccountentrylistBean.setAppId("AutoTest");
			String beginTime=YMTDateUtil.getBeforeOrNextDay(-1);
			String endTime=YMTDateUtil.getBeforeOrNextHour(1);		
			getaccountentrylistBean.setBeginTime(beginTime);
			getaccountentrylistBean.setEndTime(endTime);
			int accountingType=1;
			getaccountentrylistBean.setAccountingType(accountingType);
			int entryType=2;
			getaccountentrylistBean.setEntryType(entryType);
			int accountType=1;
			getaccountentrylistBean.setAccountType(accountType);
			int currencyType=1;
			getaccountentrylistBean.setCurrencyType(currencyType);
			getaccountentrylistBean.setPageIndex(pageIndex);
			getaccountentrylistBean.setPageSize(pageSize);
			getaccountentrylistBean.setBizCode(bizCode);
			getaccountentrylistCall.setData(getaccountentrylistBean);
			getaccountentrylistCall.callService();
			Logger.verifyEquals(0, getaccountentrylistCall.getStatuscode(), "验证接口查询结果返回statusCode");
			Logger.verifyEquals(ECode.ACCOUNT_SUCCESS, getaccountentrylistCall.getMsg(), "验证提示信息成功");
			// 验证返回是userid
			ArrayList<AccountEntryBean> returnAccountList = getaccountentrylistCall.getReturnAccountList();
			Logger.verifyEquals(size, returnAccountList.size(), "验证size");
			
			for (AccountEntryBean accountEntryBean : returnAccountList) {
				Logger.verifyEquals(userid, accountEntryBean.getUserId(), "验证Userid");
				Logger.verifyEquals(bizCode, accountEntryBean.getBizCode(), "验证BizCode");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}